<!DOCTYPE html>
<html lang=zh>
<head>
    <meta charset="utf-8">
    

    <meta name="baidu-site-verification" content="lt822VnP06" />
    <meta name="baidu-site-verification" content="0Ajixw1Puk" />
    <meta name="google-site-verification" content="gCQD0Y6f0YlPTZTAjp_mqms4C7TlkMWrg3Xy0mFdMwI" />
    <title>滚蛋吧~ XML 君 | Giraffe&#39;s Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="Long long time ago, 在《Spring In Action》一书中看到这么一句话 JavaConfig is the preferred option for explicit configuration because it’s more powerful, type-safe, and refactor-friendly 。不过当时并不知道 JavaConfig 是神马东东">
<meta property="og:type" content="article">
<meta property="og:title" content="滚蛋吧~ XML 君">
<meta property="og:url" content="http://yemengying.com/2016/10/15/javaConfig-vs-XML/index.html">
<meta property="og:site_name" content="Giraffe's Home">
<meta property="og:description" content="Long long time ago, 在《Spring In Action》一书中看到这么一句话 JavaConfig is the preferred option for explicit configuration because it’s more powerful, type-safe, and refactor-friendly 。不过当时并不知道 JavaConfig 是神马东东">
<meta property="og:image" content="https://pic.yupoo.com/jiananshi/38ad3eff/2a9a8d29.jpg">
<meta property="og:updated_time" content="2018-12-13T07:33:20.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="滚蛋吧~ XML 君">
<meta name="twitter:description" content="Long long time ago, 在《Spring In Action》一书中看到这么一句话 JavaConfig is the preferred option for explicit configuration because it’s more powerful, type-safe, and refactor-friendly 。不过当时并不知道 JavaConfig 是神马东东">
<meta name="twitter:image" content="https://pic.yupoo.com/jiananshi/38ad3eff/2a9a8d29.jpg">
    

    

    
        <link rel="icon" href="https://yemengying.com/qiniu/image/image/favicon.png" />
    


    <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/lib/open-sans/styles.css">
    <link rel="stylesheet" href="/lib/source-code-pro/styles.css">

    <link rel="stylesheet" href="/css/style.css">

    <script src="/lib/jquery/2.1.3/jquery.min.js"></script>
    
    
        <link rel="stylesheet" href="/lib/fancybox/jquery.fancybox.css">
    
    
        <script type="text/javascript">
(function(i,s,o,g,r,a,m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function() {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-75861791-1', 'auto');
ga('send', 'pageview');

</script>
    
    
    
        <script>
var _hmt = _hmt || [];
(function() {
    var hm = document.createElement("script");
    hm.src = "//hm.baidu.com/hm.js?44bb8bfb1a576270255713e37746eb82";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();
</script>

    

</head>
<body>
    <script src="//github.elemecdn.com/jiananshi/req/0.1.0/lib/req.js"></script>
    <script src="//npm.elemecdn.com/jinkela@1.2.18/umd.js"></script>
    <script src="//github.elemecdn.com/jiananshi/DisqusJS/2.0.8/index.js"></script>
    <div id="container">
        <header id="header">
    <div id="header-main" class="header-inner">
        <div class="outer">
            <a href="/" id="logo">
                <i class="logo"></i>
                <span class="site-title">Giraffe&#39;s Home</span>
            </a>
            <nav id="main-nav">
                
                    <a class="main-nav-link" href="/.">首页</a>
                
                    <a class="main-nav-link" href="/archives">归档</a>
                
                    <a class="main-nav-link" href="/categories">分类</a>
                
                    <a class="main-nav-link" href="/tags">标签</a>
                
                    <a class="main-nav-link" href="/about">关于</a>
                
                    <a class="main-nav-link" href="/message">留言</a>
                
                    <a class="main-nav-link" href="/friends">友链</a>
                
                    <a class="main-nav-link" href="/reading">正在读...</a>
                
            </nav>
            
                
                <nav id="sub-nav">
                    <div class="profile" id="profile-nav">
                        <a id="profile-anchor" href="javascript:;">
                            <img class="avatar" src="https://pic.yupoo.com/jiananshi/e85e4303/735cf286.jpeg" />
                            <i class="fa fa-caret-down"></i>
                        </a>
                    </div>
                </nav>
            
            <div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="想要查找什么..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>

</div>
        </div>
    </div>
    <div id="main-nav-mobile" class="header-sub header-inner">
        <table class="menu outer">
            <tr>
                
                    <td><a class="main-nav-link" href="/.">首页</a></td>
                
                    <td><a class="main-nav-link" href="/archives">归档</a></td>
                
                    <td><a class="main-nav-link" href="/categories">分类</a></td>
                
                    <td><a class="main-nav-link" href="/tags">标签</a></td>
                
                    <td><a class="main-nav-link" href="/about">关于</a></td>
                
                    <td><a class="main-nav-link" href="/message">留言</a></td>
                
                    <td><a class="main-nav-link" href="/friends">友链</a></td>
                
                    <td><a class="main-nav-link" href="/reading">正在读...</a></td>
                
                <td>
                    
    <div class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
    </div>

                </td>
            </tr>
        </table>
    </div>
</header>

        <div class="outer">
            
                

<aside id="profile">
    <div class="inner profile-inner">
        <div class="base-info profile-block">
            <img id="avatar" src="https://pic.yupoo.com/jiananshi/e85e4303/735cf286.jpeg" />
            <h2 id="name">Giraffe</h2>
            <h3 id="title">Java Developer</h3>
            <span id="location"><i class="fa fa-map-marker"></i>Shanghai, China</span>
            <a id="follow" target="_blank" href="https://github.com/giraffe0813/">关注我</a>
        </div>
        <div class="article-info profile-block">
            <div class="article-info-block">
                56
                <span>文章</span>
            </div>
            <div class="article-info-block">
                36
                <span>标签</span>
            </div>
        </div>
        <div class="profile-block recent-comments">
            <p class="recent-comments-title">最新评论</p>
            <ul id="disqus-recent-comments" class="recent-comments-container">
            </ul>
        </div>
        
        <div class="profile-block social-links">
            <table>
                <tr>
                    
                    
                    <td>
                        <a href="http://github.com/giraffe0813" target="_blank" title="github" class=tooltip>
                            <i class="fa fa-github"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/atom.xml" target="_blank" title="rss" class=tooltip>
                            <i class="fa fa-rss"></i>
                        </a>
                    </td>
                    
                </tr>
            </table>
        </div>
        
    </div>
</aside>

            
            <section id="main"><article id="2016/10/15/javaConfig-vs-XML/" class="article article-type-post" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
        
            <header class="article-header">
                
    
        <h1 class="article-title" itemprop="name">
            滚蛋吧~ XML 君
        </h1>
    

                <div class="article-meta">
                    
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/10/15/javaConfig-vs-XML/">
            <time datetime="2016-10-15T07:20:20.000Z" itemprop="datePublished">2016-10-15</time>
        </a>
    </div>


                    
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/java/">java</a>
    </div>

                    
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/java/">java</a>, <a class="tag-link" href="/tags/spring/">spring</a>
    </div>

                </div>
            </header>
        
        <div class="article-entry" itemprop="articleBody">
        
            
                <div id="toc" class="toc-article">
                <strong class="toc-title">文章目录</strong>
                    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#XML"><span class="toc-number">1.</span> <span class="toc-text">XML</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#JavaConfig"><span class="toc-number">2.</span> <span class="toc-text">JavaConfig</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#JavaConfig-与-XML"><span class="toc-number">3.</span> <span class="toc-text">JavaConfig 与 XML</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#总结"><span class="toc-number">4.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#相关文档"><span class="toc-number">5.</span> <span class="toc-text">相关文档</span></a></li></ol>
                </div>
            
            <blockquote>
<p>Long long time ago, 在《Spring In Action》一书中看到这么一句话<strong> JavaConfig is the preferred option for explicit configuration because it’s more powerful, type-safe, and refactor-friendly </strong>。不过当时并不知道 <code>JavaConfig</code> 是神马东东就选择性忽略了。最近新的项目采用了 Spring Boot + JavaConfig ,接触了一个星期的 JavaConfig，感觉还不错，简单比较下它和 XML。由于接连看了 4 部韩国灾难片心情比较蓝瘦，就暂时不要指正错误了，错就错吧(づ｡◕‿‿◕｡)づ</p>
</blockquote>
<a id="more"></a>
<p><img src="https://pic.yupoo.com/jiananshi/38ad3eff/2a9a8d29.jpg" alt="lalala"></p>
<h3 id="XML"><a href="#XML" class="headerlink" title="XML"></a>XML</h3><p>虽然早在 Spring 3 中就开始支持以 <code>JavaConfig</code> 的方式配置项目，但感觉目前主流的还是以 <code>XML + Annotation</code> 的方式，很少见到使用 JavaConfig 的。可能有点以偏概全了，但在前司和前前司接触到的项目都是以 XML + Annotation 混合的方式配置的，即在 XML 配置文件中开启注解扫描, 业务 bean 的配置注入采用注解( @Serivce, @Autowire 等等)，全局的一些配置(如 MyBatis 的 DataSource,SqlSessionFactory ，web.xml 等等)使用 XML。</p>
<p>虽然 XML + Annotation 的方式比纯用 XML 配置的方式少写了很多 XML，但本质上还是基于 XML 的。</p>
<p>XML 的配置文件比较冗长，不易书写，而且可读性也不高。不知道大家感觉怎么样，反正我看着是挺头疼的╥﹏╥…</p>
<h3 id="JavaConfig"><a href="#JavaConfig" class="headerlink" title="JavaConfig"></a>JavaConfig</h3><p>先简单介绍一下 JavaConfig，JavaConfig即Java Configuration, 即用纯 Java 的方式来配置 Spring<br> IoC 容器,允许开发者用代码来表示配置逻辑，不再需要 XML。粗略翻了两本关于 Spring Boot的书， JavaConfig 都是最推荐的配置方式。</p>
<p>使用 JavaConfig 的好处，Spring 官方文档中说的很清楚：</p>
<ol>
<li>JavaConfig 为依赖注入提供了一个真正面向对象的机制，这意味着开发者可以在配置代码中充分利用 Java 重用、继承和多态性等特性。</li>
<li>开发者可以完全控制实例化和依赖注入，即使是最复杂的对象也可以很优雅地处理。</li>
<li>因为使用 JavaConfig 只需要 Java，可以很容易的 refactor 代码，而无需再 IDE 之外使用特殊的工具或插件。</li>
</ol>
<p>JavaConfig 其实很简单，主要是通过 @Configuration 和 @Bean 来进行配置。@Configuration 注解的作用是声明当前类是一个配置类， 就相当于一个 XML 文件。 @Bean 注解声明当前方法返回的是一个 bean。</p>
<p>可能这样说对于用惯了 XML 的人还是比较抽象的，下面看看这些注解与 XML 配置的对应关系。</p>
<h3 id="JavaConfig-与-XML"><a href="#JavaConfig-与-XML" class="headerlink" title="JavaConfig 与 XML"></a>JavaConfig 与 XML</h3><p>1.<br><strong>JavaConfig</strong>: @Configuration<br><strong>XML</strong>:</p>
  <figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</div><div class="line"><span class="tag">&lt;<span class="name">beans</span> <span class="attr">xmlns</span>=<span class="string">"http://www.springframework.org/schema/beans"</span></span></div><div class="line">      <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></div><div class="line">      <span class="attr">xmlns:tx</span>=<span class="string">"http://www.springframework.org/schema/tx"</span></div><div class="line">      <span class="attr">xmlns:util</span>=<span class="string">"http://www.springframework.org/schema/util"</span></div><div class="line">      <span class="attr">xmlns:p</span>=<span class="string">"http://www.springframework.org/schema/p"</span></div><div class="line">      <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://www.springframework.org/schema/beans</span></div><div class="line">  	   http://www.springframework.org/schema/beans/spring-beans.xsd</div><div class="line">      http://www.springframework.org/schema/tx</div><div class="line">  	   http://www.springframework.org/schema/tx/spring-tx.xsd</div><div class="line">      http://www.springframework.org/schema/util</div><div class="line">      http://www.springframework.org/schema/util/spring-util.xsd"&gt;	</div><div class="line">   </div><div class="line"><span class="tag">&lt;/<span class="name">beans</span>&gt;</span></div></pre></td></tr></table></figure>
<p>2.<br><strong>JavaConfig</strong>: @Bean<br><strong>XML</strong>:</p>
  <figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">bean</span> <span class="attr">id</span>=<span class="string">"dataSource"</span> <span class="attr">class</span>=<span class="string">"com.alibaba.druid.pool.DruidDataSource"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"url"</span> <span class="attr">value</span>=<span class="string">"jdbc:mysql://127.0.0.1:3307/giraffe"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"username"</span> <span class="attr">value</span>=<span class="string">"ymy"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"password"</span> <span class="attr">value</span>=<span class="string">"666666"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">bean</span>&gt;</span></div></pre></td></tr></table></figure>
<p>3.<br><strong>JavaConfig</strong>：@ComponentScan<br><strong>XML</strong>：<br>  <figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">context:component-scan</span>&gt;</span></div></pre></td></tr></table></figure></p>
<p>4.<br><strong>JavaConfig</strong>：@Import<br><strong>XML</strong>：<br>   <figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">import</span> <span class="attr">resource</span>=<span class="string">"XXX.xml"</span>/&gt;</span></div></pre></td></tr></table></figure></p>
<p>比如要配置一个 dataSource， 在 XML 中通常的做法是这样的：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">bean</span> <span class="attr">id</span>=<span class="string">"drMainDataSource"</span> <span class="attr">class</span>=<span class="string">"com.alibaba.druid.pool.DruidDataSource"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"url"</span> <span class="attr">value</span>=<span class="string">"$&#123;mysql.datasource.url&#125;"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"username"</span> <span class="attr">value</span>=<span class="string">"$&#123;mysql.datasource.username&#125;"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"password"</span> <span class="attr">value</span>=<span class="string">"$&#123;mysql.datasource.password&#125;"</span>/&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">"maxActive"</span> <span class="attr">value</span>=<span class="string">"&#123;mysql.datasource.max-active&#125;"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">bean</span>&gt;</span></div></pre></td></tr></table></figure>
<p>对应的 JavaConfig 是酱紫的：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Configuration</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DataAccessConfig</span> <span class="keyword">extends</span> <span class="title">ConfigurationSupport</span> </span>&#123;</div><div class="line">  <span class="meta">@Bean</span>(name = <span class="string">"dataSource"</span>)</div><div class="line">  <span class="function"><span class="keyword">public</span> DataSource <span class="title">mysqlDataSource</span><span class="params">(@Value(<span class="string">"$&#123;mysql.datasource.url&#125;"</span>)</span> String url,</span></div><div class="line">                                    @<span class="title">Value</span><span class="params">(<span class="string">"$&#123;mysql.datasource.username&#125;"</span>)</span> String username,</div><div class="line">                                    @<span class="title">Value</span><span class="params">(<span class="string">"$&#123;mysql.datasource.password&#125;"</span>)</span> String password,</div><div class="line">                                    @<span class="title">Value</span><span class="params">(<span class="string">"$&#123;mysql.datasource.driverClass&#125;"</span>)</span> String driver,</div><div class="line">                                    @<span class="title">Value</span><span class="params">(<span class="string">"$&#123;mysql.datasource.max-active&#125;"</span>)</span> <span class="keyword">int</span> maxActive) &#123;</div><div class="line"></div><div class="line">    DruidAbstractDataSource dataSource = <span class="keyword">new</span> DruidDataSource();</div><div class="line">    dataSource.setDriverClassName(driver);</div><div class="line">    dataSource.setUrl(url);</div><div class="line">    dataSource.setUsername(username);</div><div class="line">    dataSource.setPassword(password);</div><div class="line">    dataSource.setMaxActive(maxActive);</div><div class="line">    <span class="keyword">return</span> dataSource;</div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>虽然才接触了一周的 JavaConfig, 但是相见恨晚啊, 个人还是更喜欢 JavaConfig 的配置方式的。JavaConfig 的配置文件可读性更高也更容易学习，记住简单的几个注解即可；借助 IDE 的力量，更不容易出错；而且脑袋再也不用在 Java 和 XML 间来回切换了，在搭配上 Gradle 简直破费科特！！！！！</p>
<p><img src="https://pic.yupoo.com/jiananshi/5417f84e/5cd518b1.png" alt="开森"></p>
<h3 id="相关文档"><a href="#相关文档" class="headerlink" title="相关文档"></a>相关文档</h3><ul>
<li><a href="http://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/pr01.html" target="_blank" rel="external">Spring JavaConfig Document</a></li>
<li>《Spring Boot 揭秘》</li>
</ul>
<p>——————————————-片 尾 彩 蛋 🎉🎉🎉—————————————————<br>咳咳，预警预警！！！下面的部分与本文主旨无关。</p>
<p>首先，换了个新锅，可以预约煮粥，再也不用早起煮粥了，幸福感提升 200%。<br><img src="https://pic.yupoo.com/jiananshi/e5c5a4fc/83a101e1.jpg" alt="我是锅"><br>其次，在匿名人士的帮助下上线了新版未翻墙模式下的评论，优化了样式。唉，这是谁的男朋友这么有才华，好羡慕她哦︿(￣︶￣)︿<br><img src="https://pic.yupoo.com/jiananshi/9eeb1071/d6b98de8.png" alt="&lt;(￣︶￣)&gt;"></p>
<p>最后，嘿嘿，关注个公众号再走吧(<em>^__^</em>)<br><img src="https://pic.yupoo.com/jiananshi/3302bb60/7b8457af.jpg" alt="Running Geek"></p>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yemengying.com/2016/10/15/javaConfig-vs-XML/" data-id="cjtvbucic001zz15s37ee8lg6" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yemengying.com/2016/10/15/javaConfig-vs-XML/#comments" class="article-comment-link disqus-comment-count" data-disqus-url="http://yemengying.com/2016/10/15/javaConfig-vs-XML/">评论</a>
    

        </footer>
    </div>
    
        
<nav id="article-nav">
    
        <a href="/2016/10/27/runningman-7012/" id="article-nav-newer" class="article-nav-link-wrap">
            <strong class="article-nav-caption">上一篇</strong>
            <div class="article-nav-title">
                
                    Running Man 7012
                
            </div>
        </a>
    
    
        <a href="/2016/09/11/solid-go-design-1/" id="article-nav-older" class="article-nav-link-wrap">
            <strong class="article-nav-caption">下一篇</strong>
            <div class="article-nav-title">【译】S.O.L.I.D 原则在 Go 中的应用（上）</div>
        </a>
    
</nav>


    
    <script>
   DisqusJS.getArticleComments();
   </script>
</article>


    
    <section id="comments">
    
        
    <div id="disqus_thread">
        <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    </div>

    
    </section>

</section>
            
        </div>
        <footer id="footer">
    <div class="outer">
        <div id="footer-info" class="inner">
            &copy; 2019 Mengying Ye<br>
            Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
        </div>
    </div>
</footer>
        
    
   <script>
   DisqusJS.getRecentComments(document.querySelector('#disqus-recent-comments'));
   </script>



    
        <script src="/lib/fancybox/jquery.fancybox.pack.js"></script>
    


<!-- Custom Scripts -->
<script src="/js/main.js"></script>

    </div>
</body>
</html>
